package com.example.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.pojo.Belaidup;
import com.example.service.CgRkService;
import com.example.service.publi;
import com.example.vo.PageBean1;

@Controller
@RequestMapping("/cgrk")
public class CgRkController {
@Autowired
private CgRkService service;	
@Autowired
private publi p1;
/*进入采购入库*/
@RequestMapping("/index")
public String index(){ 
	return "Cgrk" ;
}
/*获取单号*/
@ResponseBody
@RequestMapping("/danhao")
public String danhao(String date){
	if(date==null|| date==""){
		date=new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		System.out.println(date);
	}
	
	
	return p1.danhao(date, "belaidup", "BillNo");
}

/*查询记录*/
@ResponseBody
@RequestMapping("/list")
public Object inse(int page){
	page--;
	System.out.println(page+"...............................................");
	PageBean1 p=new PageBean1();
	p.setPagesize(1);
	p.setRowcount(service.SelectCount());
	p.setPagenum(page);
	p.setPagedata(service.list(page));
	return p ;
}
/*主祥新增*/
@ResponseBody
@RequestMapping("/insert")
public void insert(@RequestBody  Belaidup b){
	 service.Insert(b);
}
/*修改主表状态为已审核*/
@ResponseBody
@RequestMapping("/update1")
public void update1(@RequestBody  Belaidup b){
	service.update1(b);
}
/*修改主表状态为未审核*/
@ResponseBody
@RequestMapping("/update2")
public void update2(String id){
	service.update2(id);
}
/*删除主表*/
@ResponseBody
@RequestMapping("/update3")
public void update3(String id){
	service.update3(id);
}

/*查询记录*/
@ResponseBody
@RequestMapping("/find1")
public Object clist(String no){
	return service.findor1(no);
}
//采购订单转单查询
@ResponseBody
@RequestMapping("/findorder")
public Object  findorder( String time){
	return service.findorder(time);
	
}

}
